/* Copyright 2009 Sony Mathew, Minneapolis MN. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */
package com.xsm.muck.control;

import com.xsm.lite.event.RemoteControl;
import com.xsm.muck.lite.event.OnyDoneEvent;
import com.xsm.muck.lite.event.RonyEvent;
import com.xsm.muck.lite.event.SonyEvent;

/**
 * A very light simple RemoteCOntrol for handling chat events sent to us remotely.
 * 
 * @author Sony Mathew
 */
public class MuckRemoteControlImpl extends RemoteControl implements MuckRemoteControl, SonyEvent.Processor, RonyEvent.Processor  {

    /**
     * My IoC Dependencies.
     */
    public interface Context extends RemoteControl.Context {
    }
    
    private final Context cxt;
    
    public MuckRemoteControlImpl(Context cxt) {
        super(cxt);
        this.cxt = cxt;
        process(SonyEvent.class);
        process(RonyEvent.class);
        //TonyEvent Not being processed intentionally to show error that occurs (watch server console).
    }

    /**
     * @see com.xsm.muck.control.MuckRemoteControl#tellSony()
     */
    public String tellSony(String sonySays) {
        return "Hi Sony, Thankyou for RPC'ing me, got your message: " + sonySays;
    }

    /**
     * @see com.xsm.muck.control.MuckRemoteControl#tellRony()
     */
    public String tellRony(String ronySays) {
        return "Hi Rony, Thankyou for RPC'ing me, got your message: " + ronySays;
    }
    
    public OnyDoneEvent process(SonyEvent e) {
        String sonyMsg = tellSony(e.getMsg());
        OnyDoneEvent onyDoneEvent = new OnyDoneEvent(e.getKey(), sonyMsg);
        return onyDoneEvent;
    }

    public OnyDoneEvent process(RonyEvent e) {
        String ronyMsg = tellRony(e.getMsg());
        OnyDoneEvent onyDoneEvent = new OnyDoneEvent(e.getKey(), ronyMsg);
        return onyDoneEvent;
    }
    
    //    
    //TonyEvent Not being processed intentionally to show error that occurs (watch server console).
    //
}
